//
//  FFileManager.m
//  o_amap
//
//  Created by 胡凯 on 2023/2/11.
//

#import "FFileManager.h"

@implementation FFileManager

static FFileManager *_instance = nil;
+ (instancetype)defaultCenter {
    return [[FFileManager alloc] init];
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone {
     @synchronized(self) { // 同步
        if (!_instance) {
            _instance = [super allocWithZone:zone];
        }
    }
    return _instance;
}
 
- (instancetype)copyWithZone:(struct _NSZone *)zone {
    return _instance;
}

- (instancetype)mutableCopyWithZone:(nullable NSZone *)zone {
    return _instance;
}

/// 获取flutter端图片资源路径
- (nullable NSString *)pathForFlutterImageName:(nullable NSString *)imageName {
    if (!_registar || !imageName) return nil;
//    NSLog(@"%@ == %@", _registar, imageName);
//    NSLog(@">>%@", [_registar lookupKeyForAsset:imageName]);
//    NSLog(@">>%@", [NSBundle mainBundle]);
    return [[NSBundle mainBundle] pathForResource:[_registar lookupKeyForAsset:imageName] ofType:nil];
}
/// 获取flutter端文件资源路径
- (nullable NSString *)pathForFlutterFileName:(nullable NSString *)fileName {
    if (!_registar || !fileName) return nil;
    return [[NSBundle mainBundle] pathForResource:[_registar lookupKeyForAsset:fileName] ofType:nil];
}

@end
